package com.ebook.ui.fragment.home.everyrecommend;

import com.ebook.entity.User;

import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class ImgContainer extends JComponent {
    private final Image image;
    public ImgContainer(Image image, BookSummary bookSummary){
        super();
        this.image = image;
        this.setLocation(17,10);
        this.setSize(120,130);
        this.addMouseListener(new MouseAdapter(){
            @Override
            public void mouseClicked(MouseEvent e){
                try {
                    bookSummary.notifyBookDetails();
                } catch (NoSuchFieldException | IllegalAccessException ex) {
                    ex.printStackTrace();
                }
            }
        });
    }
    public ImgContainer(Image image, User user){
        super();
        this.image = image;
        User c_user = user;
        this.setBounds(0,0,40,40);
    }
    public void paintComponent(Graphics g){
        super.paintComponent(g);
        g.drawImage(image, 0,0,getWidth(),getHeight(),this);
    }
}
